package com.htime.controller;

import com.htime.domain.CommonRes;
import com.htime.exception.RcException;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by HTime on 2017/3/5.
 */
@RestController
public class HelloRestController {

    private Logger logger = Logger.getLogger(getClass());

    @RequestMapping("/hello")
    public String hello() throws Exception {
        logger.info("HelloRestController hello");
        return "Hello World!";
    }

    @RequestMapping("/hello/1")
    public String hello1() throws Exception {
        throw new Exception("runtime 异常");
    }

    @RequestMapping("/hello/2")
    public String hello2() throws Exception {
        throw new RcException("使用默认的error code");
    }

    @RequestMapping("/hello/3")
    public String hello3() throws Exception {
        throw new RcException(CommonRes.RES_DAOEXCEPTION, "指定error code");
    }

}
